/*!
 * \file frcap_set_cs_srv.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    int i_ret = 0;
    Conntrack *p_st_ct = NULL;
    u_int ui_ip = 1;
    u_short us_port = 2;

    i_ret = frcap_set_cs_srv(p_st_ct, ui_ip, us_port);

    CU_ASSERT_EQUAL(i_ret,FR_FAIL);
    return;

}

static void __case2(void)
{
    int i_ret = 0;
    Conntrack *p_st_ct = NULL;
    u_int ui_ip = 1;
    u_short us_port = 2;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct,0x00,sizeof(Conntrack));

    p_st_ct->src_ip = 1;
    p_st_ct->src_port = 2;

    i_ret = frcap_set_cs_srv(p_st_ct, ui_ip, us_port);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    frfree(p_st_ct);
    return;
}

static void __case3(void)
{
    int i_ret = 0;
    Conntrack *p_st_ct = NULL;
    u_int ui_ip = 3;
    u_short us_port = 4;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct,0x00,sizeof(Conntrack));

    p_st_ct->dst_ip = 3;
    p_st_ct->dst_port = 4;

    i_ret = frcap_set_cs_srv(p_st_ct, ui_ip, us_port);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    frfree(p_st_ct);
    return;
}

static void __case4(void)
{
    int i_ret = 0;
    Conntrack *p_st_ct = NULL;
    u_int ui_ip = 3;
    u_short us_port = 4;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct,0x00,sizeof(Conntrack));

    p_st_ct->src_ip = 1;
    p_st_ct->dst_port = 4;
    

    i_ret = frcap_set_cs_srv(p_st_ct, ui_ip, us_port);

    CU_ASSERT_EQUAL(i_ret,FR_FAIL);
    frfree(p_st_ct);
    return;
}





int add_suite_frcap_set_cs_srv(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frct_comm frcap_set_cs_srv()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);

    return FR_SUCC;
}
